﻿@using Webdiyer.WebControls.Mvc
@model PagedList<NationalIT.Company_Expanses>
@{
    ViewBag.Title = "Company Expanses";
}
<div class="row-fluid">
    <div class="span12">
        <div class="row-fluid">
            <div class="span12">
                @Html.Partial("_MenuButtonNewEditOrDelete")
            </div>
        </div>
        <table class="table">
            <tr>
                <th>
                    <input type="checkbox" name="" value="" class="checkAll" />
                </th>
                <th>
                    ID
                </th>
                <th>
                    Expanses
                </th>
                <th>
                    Amount
                </th>
                <th>
                    Date
                </th>
                <th>
                    Comment
                </th>
                <th>
                    Dispatcher
                </th>
            </tr>
            @foreach (var item in Model)
            {
                <tr>
                    <td>
                        <input type="checkbox" name="checkOwner" value="@item.CompanyExpansesID" class="checkitem"/>
                    </td>
                    <td>
                        @Html.ActionLink(item.CompanyExpansesID.ToString(), "NewOrEdit", new { id = item.CompanyExpansesID })
                    </td>
                    <td>
                        @item.Expanses
                    </td>
                    <td>
                        @String.Format("{0:C}", item.Amount)
                    </td>
                    <td>
                        @(item.Date.HasValue ? item.Date.Value.ToString("MM/dd/yyyy") : "")
                    </td>
                    <td>
                        @item.Comment
                    </td>
                    <td>
                        @{var dis = NationalIT.DB.Entities.Dispatchers.FirstOrDefault(m => m.ID == item.ApprovedBy);
                        }
                        @(dis == null ? "" : dis.Last_name + " " + dis.First_name)
                    </td>
                </tr>
            }
        </table>
        <div class="row-fluid">
            <div class="span4">
                <div class="dataTables_info">
                    @if (Model.TotalItemCount > 0)
                    {
                        if (Model.TotalItemCount < Model.PageSize)
                        {
                        <span>1 </span>
                        <span>- </span>@Model.TotalItemCount
                        }
                        else
                        {
                        <span></span>@((Model.CurrentPageIndex - 1) * Model.PageSize + 1)
                        <span>- </span>@((Model.CurrentPageIndex != Model.TotalPageCount) ? (Model.CurrentPageIndex * Model.PageSize) : Math.Abs((Model.CurrentPageIndex) * Model.PageSize - (Model.PageSize * Model.TotalPageCount) - Model.TotalItemCount))
                        }
                        <span>of </span>@(Model.TotalItemCount)
                            
                    }
                </div>
            </div>
            <div class="span8">
                <div class="dataTables_paginate paging_bootstrap pagination phantrangmvcpager">
                    @* <ul>
                        <li class="prev disabled"><a href="#">← Prev</a></li><li class="active"><a href="#">
                            1</a></li><li><a href="#">2</a></li><li class="next"><a href="#">Next → </a>
                        </li>
                    </ul>*@
                    @Html.Pager(Model, new PagerOptions { ContainerTagName = "ul", PageIndexParameterName = "page", CurrentPagerItemWrapperFormatString = "<li class='active'>{0}</li>", CurrentPageNumberFormatString = "{0}", FirstPageText = "&laquo; ", LastPageText = " &raquo;", NextPageText = "Next →", PrevPageText = "← Prev", SeparatorHtml = "" })
                </div>
            </div>
        </div>
    </div>
</div>
